 <script src="__PUBLIC__/js/bootstrap-datepicker.min.js"></script>
 <script src="__PUBLIC__/locales/bootstrap-datepicker.zh-CN.min.js" charset="UTF-8"></script>
 <link id="bsdp-css" href="__PUBLIC__/css/bootstrap-datepicker3.min.css" rel="stylesheet">
 <script type="text/javascript">
     $(function () {
        $('[data-toggle="tooltip"]').tooltip();
        $('input[name="packageend"]').datepicker({
            format: "yyyy-mm-dd",
            todayBtn: "linked",
            language: "zh-CN",
            autoclose: true
        }).on('changeDate', function(ev) {
            //alert(ev.date.valueOf());
            var packageend = ev.date.valueOf();
            $.get("__APP__/Userlevel/getpackageend/userid/{$userid}/packageend/"+packageend,function(e){
                var recordprice = parseInt($('#single').html()) ;
                //alert(recordprice);
                $("#countlimit").html(e.countlimit);
                $('#package').html("￥"+recordprice*parseInt(e.countlimit));
            });
        });

        $("select[name='level']").change(function(){
            var level = $("select[name='level']").val();
            $.get("__APP__/Userlevel/getprice/level/"+level,function(e){
                $('#single').html(e.recordprice);
                $('#multi').html(e.subprice);
                $('#discuss').html(+e.discussprice);
                var recordprice = e.recordprice;
                var count = parseInt($('#countlimit').text()) ;
                $('#package').html(recordprice*count);
            });
        });
    });


 </script>

 <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-header"><i class="fa fa-chevron-left" onclick="closeurl();"></i>用户等级管理</h3>
                </div>
                <!-- /.col-lg-12 -->
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-green">
                        <div class="panel-heading">
                            用户简介
                        </div>
                        <div class="panel-body">
                            <div class="media">
                              <div class="media-left">
                                <a href="#">
                                  <img class="media-object" src="<if condition="$user.image eq ''">{$user.headimgurl}<else />{$user.image}</if>" alt="用户头像" width="100">
                                </a>
                              </div>
                              <div class="media-body">
                                <h4 class="media-heading"><b>{$user.name}</b></h4>
                                <p>
                                {:L('hospital')}:{$user.hospital}
                                {:L('address')}:{$user.address}
                                </p>
                                <p>
                                {:L('department')}:{$user.department}
                                {:L('position')}:{$user.position}
                                {:L('socialposition')}:{$user.socialposition}
                                </p>
                                <p>
                                {:L('mobile')}:{$user.mobile}
                                {:L('email')}:{$user.email}
                                </p>
                              </div>
                            </div>  
                        </div>
                        <div class="panel-footer">
                            <form class="form-inline">
                            <div class="row">
                                <div class="col-md-10">
                                    <span class="label label-danger">当前用户等级</span>
                                    <select class="form-control" name="level">
                                        <volist name="level" id="vo">
                                            <option value="{$vo.id}" <if condition="$user['level'] eq $vo['id']">selected="selected"</if>>{$vo.level}</option>
                                        </volist>
                                    </select>
                                    单份价格：<span id="single" style="color:red;font-weight:bold;font-size:16px;">{$recordprice}</span>
                                    每月价格：<span id="multi" style="color:red;font-weight:bold;font-size:16px;">{$subprice}</span>
                                    评论价格：<span id="discuss" style="color:red;font-weight:bold;font-size:16px;">{$discussprice}</span>
                                    <button type="button" onclick = "changeLevel()" class="btn btn-primary btn-sm">更改等级</button>
                                </div>
                            </div>
                            <div style="padding:5px"></div>
                            <div class="row">
                                <div class="col-md-10">
                                    <span class="label label-info">打包截至日期</span>
                                    <input style="width:150px;" type="text" name="packageend" class="form-control" value="{$packageend}">
                                    参考价格：<span id="package" style="color:red;font-weight:bold;font-size:16px;">{$sampleprice}</span>
                                    当前价格：<input style="width:150px;" type="text" name="packageprice" class="form-control" value="{$packageprice|intval}"> 
                                    <button type="button" onclick = "changePackage()" class="btn btn-primary btn-sm">更改打包价格</button>
                                </div>
                            </div>
                            <div style="padding:5px"></div>
                            <div class="row">
                                <div class="col-md-10">
                                    <span class="label label-info">截至打包病例</span>
                                    <span id="countlimit" class="label label-default">{$countlimit}</span>
                                    <span class="label label-success">总收费病例</span>
                                    <span id="count" class="label label-default">{$count}</span>
                                </div>
                            </div>
                            </form>
                        </div>
                    </div>
              
                </div>
                <div class="col-lg-12"> </div>   
            </div>
            <!-- /.row -->
            <div class="row" id="list">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            已发布收费病例列表
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th><center>{:L('is_pics')}</center></th>
                                            <th><center>{:L('diagnostic')}</center></th>
                                            <th><center>{:L('major')}</center></th>
                                            <th><center>{:L('tp')}</center></th>
                                            <th><center>{:L('pubtime')}</center></th>
                                            <th><center>操作</center></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <volist name="records" id="vo">
                                        <tr class="odd gradeX">
                                            <td><center><img src="{$vo.image}" width="50"></center></td>
                                            <td style="vertical-align: middle;"><center>{$vo['diagnostic']}</center></td>
                                            <td style="vertical-align: middle;"><center>{$vo['major']}</center></td>
                                            <td class="center" style="vertical-align: middle;"><center>{$vo['tp']}</center></td>
                                            <td style="vertical-align: middle;">
                                                <center>
                                                    {$vo.pubtime|date="Y-m-d",###}
                                                </center>
                                            </td>
                                            <td class="center" style="vertical-align: middle;">
                                                <center>
                                                    <button type="button" class="btn btn-success btn-xs"  data-toggle="tooltip" data-placement="bottom" title="编辑用户病历" onclick="editurl('__APP__/Medicalrecord/edit/id/{$vo.id}/userid/{$userid}/pubtype/{$pubtype}/p/{$currentpage}');">
                                                        <i class="fa fa-edit"></i>
                                                    </button>
                                                </center>
                                            </td> 
                                        </tr>
                                        </volist>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                {$page}
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            
        </div>
    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script type="text/javascript">
        $.get("__APP__/Userlevel/listpage/id/{$userid}",function(e){
            $("#list").html(e);
        })

        function changeLevel(){
            var userid={$userid};
            var level = $("select[name='level']").val();
            $.post("__APP__/Userlevel/changelevel",{userid:userid,level:level},function(e){
                if(e.status==1){
                    alert('操作成功');
                }else{
                    alert('操作失败');
                }
            })
        }

        function changePackage(){
            var userid={$userid};
            var packageend = $("input[name='packageend']").val();
            var packageprice = $("input[name='packageprice']").val();
            if (isNaN(packageprice)){
                alert("打包价格不是一个整数");return;
            }
            $.post("__APP__/Userlevel/changepackage",{userid:userid,packageend:packageend,packageprice:packageprice},function(e){
                if(e.status==1){
                    alert('操作成功');
                }else{
                    alert('操作失败');
                }
            })            
        }

        function inurl(url){
            $.get(url,function(e){
                $("#list").html(e);
            })
        }
    </script>

</body>

</html>
